/**                                                                                          **
       by: Fatrat 13Sep07
  concept: A "Quest" comprises one or several missions, a "Mission" comprises several parts, 
           and the "Part" is inherited from the FSM class.

   status: pseudo code and still working on
 **                                                                                          **/

#include <string>, <vector>       // the formal C++ code should split this into
using std::string, std::vector;   // two lines but I'm just lazy


// ------- FSM --------------------------------------------------------------
// --------------------------------------------------------------------------

/*
    FSM_Part = [ s_off, p_turnOn, s_on ]
    

                      (status)
                     >  off   >
                   ^   +----+   v
    process:TurnOff()  |    |  process:TurnOn()
                   ^   +----+   v
                     <   on   <
                      (status)
*/

class FSM_Part
{
  public:  
    //member attributes(ma)
    bool status;
    bool process;
    //or
    bool  sp[2];       // {false,true} or {true,false}     

    string name;       // "s_TurnOn"

    //member functions(mf)
            void swapSP();  //status and process will only be shown in pairs: 
                            //either (s=1, p=0) or vice versa
                      
    virtual void action();                  
};

class FSM
{
  public:
    string           name; // "light_switch"
    
    vector<FSM_Part> fsm;  // fsm = 
                           // {
                           //    [ s_off, p_turnOn,  s_on  ] ,
                           //    [ s_on,  p_turnOff, s_off ]
                           // }
};      

// ------- Quest Related ----------------------------------------------------
// --------------------------------------------------------------------------
class Quest
{
  public:
    Trader*          npc;
    vector<Mission*> missions;
}; 
    
class Mission 
{
  public:    
    vector<Part*> parts;
};

class Part : FSM
{
};    



// ---------------------------------------------------------------------------
// the following should be put into the main.c file
//

Trader* trader;
Quest* quest;

quest->name = "Worried Trader";
quest->npc  = trader; 

// (to be continued)    